'use strict';

/* Controllers */
  // signin controller
app.controller('SigninFormController', ['$scope', '$http', '$state', function($scope, $http, $state) {
    $scope.user = {};
    $scope.authError = null;
    $scope.login = function() {
      $scope.authError = null;
      // Try to login
        var params = {};
        params.account =  $scope.user.account;
        params.password =  $scope.user.password;

        $http.post('multiple/user/authority', params,{"responseType":"json"}).success(function (res) {
            var code = res.code;
            var message = res.message;
            switch(code){
                case 200:$state.go('app.user.list')
                    break;
                default:  $scope.authError=message
                    break;
            }
            $scope.authError
        }).error(function () {
            $scope.authError = '服务器 错误';
        });
    };
  }])
;